import { defineStore } from 'pinia';

export const assetChart = defineStore('chart', {
  state: () => ({
    chartTitleList: [
      { name: '全部', id: 0 },
      { name: '柱状图', id: 1 },
      { name: '条形图', id: 2 },
      { name: '折线图', id: 3 },
      { name: '区域图', id: 4 },
      { name: '饼环图', id: 5 },
      { name: '散点图', id: 6 },
      { name: '雷达图', id: 7 },
      { name: '关系图', id: 8 },
    ],
    chartList: [
      {
        componentName: 'bar',
        name: '柱状图',
        url: 'https://img.alicdn.com/tfs/TB1Mmk3mKL2gK0jSZFmXXc7iXXa-332-144.png',
        parentid: 1,
        default: {
          w: 300,
          h: 200,
        },
      },
      {
        componentName: 'doughnut-chart',
        name: 'ECharts 3D环绕图',
        url: 'https://img.alicdn.com/imgextra/i1/O1CN01VjJrqJ1pn54lx9LUl_!!6000000005404-2-tps-332-144.png',
        parentid: 5,
        default: {
          w: 300,
          h: 300,
        },
      },
      {
        componentName: 'area-chart',
        name: '区域图',
        url: 'https://img.alicdn.com/tfs/TB19F.ZmFY7gK0jSZKzXXaikpXa-332-144.png',
        parentid: 4,
        default: {
          w: 200,
          h: 200,
        },
      },
      {
        componentName: 'flop-chart',
        name: '区域翻牌器',
        url: 'https://img.alicdn.com/tfs/TB1ivQ4mND1gK0jSZFKXXcJrVXa-332-144.png',
        parentid: 4,
        default: {
          w: 300,
          h: 200,
        },
      },
      {
        componentName: 'across-bar',
        name: '条形图',
        url: 'https://img.alicdn.com/imgextra/i3/O1CN01HQIkMq1x0XzKvQnO9_!!6000000006381-2-tps-332-144.png',
        parentid: 2,
        default: {
          w: 300,
          h: 200,
        },
      },
      {
        componentName: 'bubble-chart',
        name: '气泡图',
        url: 'https://img.alicdn.com/tfs/TB1XSg4mHY1gK0jSZTEXXXDQVXa-332-144.png',
        parentid: 6,
        default: {
          w: 200,
          h: 200,
        },
      },
      {
        componentName: 'radar',
        name: '双11雷达图',
        url: 'https://img.alicdn.com/tfs/TB1BWzmlUH1gK0jSZSyXXXtlpXa-160-118.png',
        parentid: 7,
        default: {
          w: 200,
          h: 200,
        },
      },
      {
        componentName: 'line',
        name: '折线图',
        url: 'https://img.alicdn.com/tfs/TB1WhGnU8r0gK0jSZFnXXbRRXXa-332-144.png',
        parentid: 3,
        default: {
          w: 300,
          h: 200,
        },
      },
    ],
  }),
  actions: {
    undateChartList(id: number) {
      this.chartList = this.chartList.filter((f) => f.parentid === id);
    },
  },
});
